let str = 'abc'
const premute = (s) => {
    const res = []
    function search(char) {
        if(char.length == s.length) {
            res.push(char)
        }
        for(let i = 0; i < s.length; i++) {
            if(!char.includes(s[i])) {
                search(char+s[i])
            }
        }
    }
    search('')
    return res
}

const res =  premute(str)
console.log(res);